package com.example.food_contract_system.controller;

import com.example.food_contract_system.service.ContractsService;
import com.example.food_contract_system.util.R;
import com.example.food_contract_system.vo.AddContractVo;
import com.example.food_contract_system.vo.ContractUpdateAndDeleteVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author LiHaoyang
 * @date 2023/7/9  15:31
 **/
@RestController
@RequestMapping("/contract")
public class ContractController {

    @Autowired
    private ContractsService contractsService;

    /**
     * 上传合同
     * @param addContractVo
     * @return
     */
    @PostMapping("/addContract")
    public R addContract(@RequestBody AddContractVo addContractVo){
        R result = contractsService.addContract(addContractVo);
        return result;
    }

    /**
     * 获取合同列表
     * @return
     */
    @GetMapping("/getContractList")
    public R getContractList(){
        R result = contractsService.getContractList();
        return result;
    }

    /**
     * 更新合同等级
     * @param contractUpdateAndDeleteVo
     * @return
     */
    @PostMapping("/updateContract")
    public R updateContract(@RequestBody ContractUpdateAndDeleteVo contractUpdateAndDeleteVo){
        R result = contractsService.updateContract(contractUpdateAndDeleteVo);
        return result;
    }

    /**
     * 删除合同
     * @param contractUpdateAndDeleteVo
     * @return
     */
    @PostMapping("/deleteContract")
    public R deleteContract(@RequestBody ContractUpdateAndDeleteVo contractUpdateAndDeleteVo){
        R result = contractsService.deleteContract(contractUpdateAndDeleteVo);
        return result;
    }

    @GetMapping("/getMainContract")
    public R getMainContract(){
        R result = contractsService.getMainContract();
        return result;
    }
}
